package com.hy.erp.inventory.service;

import java.util.List ;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

/*import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
*/
import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.CargoSpaceTypeDao;
import com.hy.erp.inventory.dao.PositionTypeDao;
import com.hy.erp.inventory.dao.interfaces.ICargoSpaceTypeDao;
import com.hy.erp.inventory.pojo.CargoSpaceType;
import com.hy.erp.inventory.pojo.interfaces.ICargoSpaceType;
import com.hy.erp.inventory.service.interfaces.ICargoSpaceTypeService;
/**
 * 
 * <ul>
 * <li>开发作者：李冰</li>
 * <li>设计日期：2010-10-13；时间：上午09:17:09</li>
 * <li>类型名称：CargoSpaceTypeService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
/*@ Name ( "cargoSpaceTypeService" )
@ Scope ( ScopeType.STATELESS )
@ Stateless*/
@Component("cargoSpaceTypeService")
public class CargoSpaceTypeService   extends AbstractBusinessService < CargoSpaceTypeDao > implements ICargoSpaceTypeService{

	
	private ICargoSpaceTypeDao cargoSpaceTypeDao=null;

	@Resource(name="cargoSpaceTypeDao")
	public void setCargoSpaceTypeDao(ICargoSpaceTypeDao cargoSpaceTypeDao) {
		this.cargoSpaceTypeDao = cargoSpaceTypeDao;
	}

	@Override
	public boolean addCargoSpaceType(CargoSpaceType cargoSpaceType) {

		if ( null == cargoSpaceType)
		{
			return true ;
		}
		
		else
		{
			System.out
						.println ("ssssssssssssssssssssssffffffffffffffffhghhhhhhhhhhhhhhhhhhhhhh") ;


		//	ICargoSpaceTypeDao cargoSpaceTypeDao =
		//	                       ( ICargoSpaceTypeDao ) this
		//	                                          .getDao ( ICargoSpaceType.class ) ;
			
			return cargoSpaceTypeDao
			                .persist ( cargoSpaceType ) ;
		}
		
	
	}

	@Override
	public boolean modifyCargoSpaceType(CargoSpaceType cargoSpaceType) {

		if ( ( null == cargoSpaceType )
			     || ( null == cargoSpaceType
			                                .getIdentifier ( ) )
			     || ( cargoSpaceType
			                        .getIdentifier ( )
			                        .trim ( )
			                        .length ( ) == 0 ) )
			{
				return true ;
			}
			else
			{

			//	ICargoSpaceTypeDao cargoSpaceTypeDao =
			//	                       ( ICargoSpaceTypeDao ) this
			//	                                          .getDao ( ICargoSpaceType.class ) ;
				
		
					
				if ( null == cargoSpaceType )
				{
					throw new ArchitectureFoundationException  (
					                                            "修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
				}
				
				
				return ( cargoSpaceTypeDao
				                  .merge ( cargoSpaceType ) != null ) ;
			}
		
	
	}

	@Override
	public Integer removeCargoSpaceType(String[] cargoSpaceTypeIds) {

		if ( ( null == cargoSpaceTypeIds)
			     || ( cargoSpaceTypeIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{


		//		ICargoSpaceTypeDao cargoSpaceTypeDao =
		//		                       ( ICargoSpaceTypeDao ) this
		//		                                          .getDao ( ICargoSpaceType.class ) ;
				return cargoSpaceTypeDao
				                .remove ( cargoSpaceTypeIds ) ;
			}
	
	}

	@ Override
	public String [ ] addCargoSpaceType (
											Object [ ] cargoSpaceType )
	{


		if ( null == cargoSpaceType)
		{
			return null ;
		}
		
		else
		{
			
		//	ICargoSpaceTypeDao cargoSpaceTypeDao =
         //       ( ICargoSpaceTypeDao ) this
         //                          .getDao ( ICargoSpaceType.class ) ;

			CargoSpaceType[] cargoSpaceTypes=new CargoSpaceType[cargoSpaceType.length];
		for(int i=0;i<cargoSpaceType.length;i++)
		{
			CargoSpaceType cargoSpaceType2=( CargoSpaceType ) cargoSpaceTypes[i];
			cargoSpaceTypes[i]=cargoSpaceType2;
		}
		return cargoSpaceTypeDao
		                .persist ( cargoSpaceTypes ) ;
		}
		
	
	
	}

	@ Override
	public List < CargoSpaceType > getAllCargoSpaceType ( )
	{

	//	ICargoSpaceTypeDao cargoSpaceTypeDao =
	//	                       ( ICargoSpaceTypeDao ) this
	//	                                          .getDao ( ICargoSpaceType.class ) ;
		return cargoSpaceTypeDao
		                .find ( ) ;
	}

	@ Override
	public String [ ] modifyCargoSpaceType (
												Object [ ] cargoSpaceType )
	{



		if ( null == cargoSpaceType)
		{
			return null ;
		}
		
		else
		{
			
	///		ICargoSpaceTypeDao cargoSpaceTypeDao =
    //            ( ICargoSpaceTypeDao ) this
    //                               .getDao ( ICargoSpaceType.class ) ;

			CargoSpaceType[] cargoSpaceTypes=new CargoSpaceType[cargoSpaceType.length];
		for(int i=0;i<cargoSpaceType.length;i++)
		{
			CargoSpaceType cargoSpaceType2=( CargoSpaceType ) cargoSpaceTypes[i];
			cargoSpaceTypes[i]=cargoSpaceType2;
		}
		return cargoSpaceTypeDao
		                .merge   ( cargoSpaceTypes ) ;
		}
		
	
	
	
	}

}
